package com.shuzijun.leetcode.editor.cn;

import java.util.ArrayList;

public class HeWeiSdeLianXuZhengShuXuLieLcof{
    public static void main(String[] args) {
         Solution solution = new HeWeiSdeLianXuZhengShuXuLieLcof().new Solution();
         solution.findContinuousSequence(9);
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[][] findContinuousSequence(int target) {
        ArrayList<int[]> result = new ArrayList<>();
        int p = 1;
        int q = 2;
        int sum = 3;
        while (p < q){
            if (sum == target){
                int[] arr = new int[q - p + 1];
                for (int i = p; i <= q; i++) {
                    arr[i-p] = i;
                }
                result.add(arr);
                sum -= p;
                p++;
                q++;
                sum += q;
            } else if (sum > target) {
                sum -= p;
                p++;
            }else {
                q++;
                sum +=q;
            }
        }

        int[][] dp = new int[result.size()][];
        for (int i = 0; i < result.size(); i++) {
            dp[i] = result.get(i);
        }

        return dp;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}